package com.itmoment.controller;

import com.itmoment.User;
import com.itmoment.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
public class UserController {
    @Autowired
    private UserService userService;
    @RequestMapping("/findAll")
    public ModelAndView findAll(){
        List<User> list = userService.findAll();
        ModelAndView mv = new ModelAndView();
        mv.addObject("list",list);
        //设置跳转页面的名称。（前缀后缀再springMVC.xml中配置）
        mv.setViewName("list");
        return mv;
    }
}
